home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / cert / trk3_eg / fmdrgdrp / opt2 / invent.exe / UTILS.BAS < prev    next >
Encoding:
BASIC Source File  |  1993-08-20  |  2.1 KB  |  78 lines

  1. Sub CenterForm (frm As Form)
  2.     frm.Left = (Screen.Width - frm.Width) / 2
  3.     frm.Top = (Screen.Height - frm.Height) / 2
  4. End Sub
  5.  
  6. Function UtilsNewFile (msg As String, fileid As String, extension As String)
  7.     On Error GoTo NewFileError
  8.     Utils.CMDialog.CancelError = True
  9.     Utils.CMDialog.Flags = OFN_OVERWRITEPROMPT
  10.     Utils.CMDialog.DefaultExt = extension
  11.     Utils.CMDialog.DialogTitle = msg + " " + fileid + " File..."
  12.     Utils.CMDialog.Filter = fileid + " files|*." + extension
  13.     Utils.CMDialog.Action = 2   ' save file
  14.     UtilsNewFile = LCase$(Utils.CMDialog.Filetitle)
  15.     Exit Function
  16. NewFileError:
  17.     UtilsNewFile = ""
  18.     Exit Function
  19. End Function
  20.  
  21. Function UtilsOpenFile (msg As String, fileid As String, Filter As String)
  22.     On Error GoTo OpenFileError
  23.     Utils.CMDialog.CancelError = True
  24.     Utils.CMDialog.Flags = OFN_FILEMUSTEXIST
  25.     Utils.CMDialog.DefaultExt = extension
  26.     Utils.CMDialog.DialogTitle = msg + " " + fileid + " File..."
  27.     Utils.CMDialog.Filter = Filter
  28.     Utils.CMDialog.Action = 1   ' open file
  29.     UtilsOpenFile = LCase$(Utils.CMDialog.Filetitle)
  30.     Exit Function
  31. OpenFileError:
  32.     UtilsOpenFile = ""
  33.     Exit Function
  34. End Function
  35.  
  36. Function ExtractBase (ByVal PathName As String) As String
  37.  
  38. ' Return the basename portion of a full pathname
  39.  
  40.     F$ = ExtractFile(PathName)
  41.     N% = InStr(F$, ".")
  42.  
  43.     If N% > 0 Then F$ = Left$(F$, N% - 1)
  44.  
  45.     ExtractBase = F$
  46.  
  47. End Function
  48.  
  49. Function ExtractFile (ByVal PathName As String) As String
  50.  
  51. ' Return the filename portion of a full pathname
  52.  
  53.     F$ = PathName
  54.  
  55.     Do
  56.         N% = InStr(F$, "\")
  57.         If N% > 0 Then F$ = Right$(F$, Len(F$) - N%)
  58.     Loop While N% > 0
  59.  
  60.     ExtractFile = F$
  61.  
  62. End Function
  63.  
  64. Function ExtractPath (ByVal PathName As String) As String
  65.  
  66. ' Return the directory path portion of a full pathname
  67.  
  68.     F$ = PathName
  69.  
  70.     Do
  71.         N% = InStr(F$, "\")
  72.         If N% > 0 Then F$ = Right$(F$, Len(F$) - N%)
  73.     Loop While N% > 0
  74.  
  75.     ExtractPath = Left$(PathName, Len(PathName) - Len(F$))
  76.  
  77. End Function
  78.